<?
include "server_config.php";

$category_id = $_GET['category'];
$question_id = $_GET['question'];


if($category_id !="" && $question_id=="")
{
	$mode_category = true;
}
else
{
	$mode_category = false;

	$sql="
		SELECT category_id FROM nddg_question WHERE id = $question_id LIMIT 1 ;
	";

	$result = mysql_query($sql,$connect);
	$row = mysql_fetch_row($result);

	$category_id = $row[0];
}


$sql="
	SELECT name FROM nddg_question_category WHERE id = $category_id LIMIT 1 ;
";

$result = mysql_query($sql,$connect);
$row = mysql_fetch_row($result);

$category_name = $row[0];

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> 넥도닥 [NextDoorDoctor] :: 데이터베이스 | <?=$category_name?> </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style>
a:link {text-decoration:none} 
a:visited {text-decoration:none} 
a:active {text-decoration:none} 
a:hover {color:blue;text-decoration:none} 
</style>

 </head>

 <body style="line-height: 160%; font-size: 12px; font-family: '굴림'; padding: 0px; margin: 0px;  ">
  <table border=0 width='1000px' align='center'>
<?
include "nddg_top_menu.php";
?>	
	<tr>
		<td>
			<div style='width:300px;float:left;'>
				질문 답변 추가

				
			</div>
			<div style='width:700px;float:left;'>
				<? 
				if($mode_category)
				{

				?>
					<b>'<?=$category_name?>'</b> 에 새 질문을 추가합니다.<br>

					<form action="nddg_db_add_do.php" method="post">
					<input type='hidden' name='c_id' value='<?=$category_id?>'>
					<br>
					질문 :<br> 
					<input type='text' name='input_question' style='width:600px;'><br>
					<br>
					답변 1 :<br>
					<textarea name='input_answer1' style='width:600px;height:100px;'></textarea><br>
					<br>
					답변 2 (선택-더 있을 경우 입력):<br>
					<textarea name='input_answer2' style='width:600px;height:100px;'></textarea><br>
					<br>
					답변 3 (선택-더 있을 경우 입력):<br>
					<textarea name='input_answer3' style='width:600px;height:100px;'></textarea><br>
					<br>
					<input type='submit' value='저장'>
					<br>
					</form>

				<?
				}
				else
				{
					$sql_sub="
						SELECT id, content, view_count, answer_count FROM nddg_question WHERE id=".$question_id." LIMIT 1 ;
					";

					$result_sub = mysql_query($sql_sub,$connect);

					$row_sub = mysql_fetch_row($result_sub);


					
				?>
					<b>'<?=$category_name?>' - '<?=$row_sub[1]?>'</b> 에 새 답변을 추가합니다.<br>

					<form action="nddg_db_add_do.php" method="post">
					<input type='hidden' name='q_id' value='<?=$question_id?>'>
					<br>
					질문 : <?=$row_sub[1]?><br> 
					<br>
					답변 1 :<br>
					<textarea name='input_answer1' style='width:600px;height:100px;'></textarea><br>
					<br>
					답변 2 (선택-더 있을 경우 입력):<br>
					<textarea name='input_answer2' style='width:600px;height:100px;'></textarea><br>
					<br>
					답변 3 (선택-더 있을 경우 입력):<br>
					<textarea name='input_answer3' style='width:600px;height:100px;'></textarea><br>
					<br>
					<input type='submit' value='저장'>
					<br>
					</form>
				<?
				}
				?>			

			</div>

			
		</td>
	</tr>
	<tr>
		<td height='10px'>
		
		</td>
	</tr>
	<tr>
		<td height='1px'>
			<div style='background:#ccc;width:1000px;height:1px;'><span></span></div>
		</td>
	</tr>
	<tr>
		<td>
			<div style='width:230px;height:50px;padding:10px; float:right; text-align:right;'>
					© 2011 Next Door Doctor
			</div>
		</td>
	</tr>
  </table>
 </body>
</html>
